package psi.springapp.mvc.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import model.Party;
import psi.springapp.mvc.service.PartyService;

import java.util.List;

/**
 * Created with IDEA.
 * Voter: Ѱ
 * Date: 28.09.14
 * Time: 10:48
 */
@Controller
@RequestMapping(value = "party")
public class PartyController {
    @Autowired
    private PartyService partyService;


    @RequestMapping(value = "all", method = RequestMethod.GET)
    @ResponseBody
    public String all() {
         partyService.partyList();
        return "partyshow";

    }

    @RequestMapping(value = "add", method = RequestMethod.PUT, consumes = "application/json")
    @ResponseStatus(HttpStatus.OK)
    public void put(@RequestBody Party party) {
        partyService.saveParty(party);
        System.out.println("party put");
    }

    @RequestMapping(value = "deleteAll", method = RequestMethod.DELETE)
    public void deleteAll() {
        partyService.deleteAll();
    }
}
